package com.open.basic.config;

import com.open.basic.spi.BasicFileManage;
import com.open.basic.spi.DefaultFileManage;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@ConditionalOnProperty(prefix = "app.file", name = "type", havingValue = "default", matchIfMissing = true)
@Configuration
public class FileConfig {

    @Value("${app.file.path:/data/doc}")
    private String path;

    @Value("${spring.application.name}")
    private String appName;

    @Bean
    public BasicFileManage basicFileManage() {
        return new DefaultFileManage(path, appName);
    }
}